﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using SharpTools.Common;
using SharpTools.Forms;
using SharpTools.DbDAL;
using SharpDB.Entity;
using ICSharpCode.TextEditor.Document;

namespace SharpTools
{
    public partial class ContentForm : DockContentForm
    {
        public ContentForm()
        {
            InitializeComponent();
           
        }

        private void ContentForm_Load(object sender, EventArgs e)
        {
            InitGrid();
        }

       

        private DB db = null;
        private DBInfo dbInfo = null;
        private List<SharpDB.Entity.ColumnInfo> lstCol = null;
        private string table_Comment = null;

        internal void InitGrid()
        {
            db = new DB(ConnectionModel.DbType, ConnectionModel.ConnectionString);
            dbInfo = db.Info;
            lstCol = dbInfo.GetAllColumnInfo(this.TableName);
            table_Comment = dbInfo.GetTableComment(TableName);
            gridColumns.DataSource = lstCol;            
        }

        private void btnSetColDisplay_Click(object sender, EventArgs e)
        {
            TableColumnDisplayForm form = new TableColumnDisplayForm();
            form.TableName = TableName;
            form.ConnectionModel = ConnectionModel;
            form.ContentThisForm = this;
            form.ShowDialog();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            InitGrid();
        }
    }
}

